package com.longsichao.lscframe.tools;

import android.content.Context;
import android.content.pm.PackageManager;

/**
 * AppInfo
 * Created by LSC on 2015/3/26.
 */
public final class AppInfo {

    public static String getAppVersionName(Context context) {
        String versionName = "";
        try {
            versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
        } catch (PackageManager.NameNotFoundException e) {
            LSCLog.e("Get app version name error.", e);
        }
        return versionName;
    }

    public static int getAppVersionCode(Context context) {
        int versionCode = 0;
        try {
            versionCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            LSCLog.e("Get app version code error.", e);
        }
        return versionCode;
    }

    private AppInfo() {
    }
}
